package com.suthund.bean.response;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.suthund.consts.NetConst;
import com.suthund.consts.ServiceError;

/**
 *
 * Created by 杨康 on 2017/4/18.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class BaseResponse {

    private String msg;

    private int status;

    private Object data;

    public BaseResponse() {
    }

    private BaseResponse(String msg, int status, Object data) {
        this.msg = msg;
        this.status = status;
        this.data = data;
    }

    public static BaseResponse ResponseSucc(String msg, Object data) {
        return new BaseResponse(msg, NetConst.SUCCESS, data);
    }

    public static BaseResponse ResponseSucc(Object data) {
        return new BaseResponse(NetConst.DEAL_SUCC, NetConst.SUCCESS, data);
    }
    public static BaseResponse ResponseSucc() {
        return new BaseResponse(NetConst.DEAL_SUCC, NetConst.SUCCESS, null);
    }

    public static BaseResponse ResponseSucc(String msg) {
        return ResponseSucc(msg, null);
    }

    public static BaseResponse ResponseFail(String msg, int status) {
        return new BaseResponse(msg, status, null);
    }

    public static BaseResponse ResponseFail() {
        return ResponseFail(NetConst.DEAL_FAIL, NetConst.FAILED);
    }


    public static BaseResponse ResponseFail(String msg) {
        return ResponseFail(msg, NetConst.FAILED);
    }

    public static BaseResponse ResponseFail(ServiceError serviceError) {
        return ResponseFail(serviceError.getMessage(), serviceError.getCode());
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
                "msg='" + msg + '\'' +
                ", status=" + status +
                ", data=" + data +
                '}';
    }
}
